﻿#include <QApplication>
#include <QTimer>
#include "testGLWidget.h"

TestGLWidget::TestGLWidget()
{
	m_timer = new QTimer(this);
	m_timer->connect(m_timer, &QTimer::timeout, this ,&TestGLWidget::onTimer);
}

void TestGLWidget::test()
{
	m_scene = new JZGLScene(this);
	m_view.setScene(m_scene);

	m_box = m_scene->addBox(QVector3D(0, 1, 0), 1, 1, 0.5);
    m_box->setDrawType(GLDraw_Line);
	for(int i = 4; i < 8; i++)
		m_box->setVertexColor(i, Qt::red);

    auto box1 = m_scene->addBox(QVector3D(0, 1, 0), 0.5, 0.5, 0.5);
    m_box->addChild(box1);

	m_timer->start(100);
	m_view.show();
}

void TestGLWidget::onTimer()
{
	//m_view.camera()->lookAtRotate(JZGLCamera::Pitch, -10);
	//m_view.camera()->lookAtRotate(JZGLCamera::Yaw, -5);
	//m_box->translate(0, 0.5f,0);
	//m_box->rotate(10, 0, 0, 1);
	//m_view.camera()->lookAtRotate(JZGLCamera::Yaw, -5);
}

int main(int argc, char* argv[])
{
	QApplication app(argc, argv);
	
	TestGLWidget t;
	t.test();

	return app.exec();
}